/*
 *    Copyright (c) 2018-2025, proj All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the proj developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: proj
 */

package com.ykht.proj.coupon.controller;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ykht.proj.admin.api.dto.UserDTO;
import com.ykht.proj.admin.api.entity.SysUser;
import com.ykht.proj.admin.api.feign.RemoteUserService;
import com.ykht.proj.admin.api.vo.UserVO;
import com.ykht.proj.common.core.util.R;
import com.ykht.proj.common.security.util.SecurityUtils;
import com.ykht.proj.coupon.Enum.LookRoleTypeEnum;
import com.ykht.proj.coupon.Enum.UserTypeEnum;
import com.ykht.proj.coupon.Enum.WorkStateEnum;
import com.ykht.proj.coupon.entity.*;
import com.ykht.proj.coupon.service.*;
import com.ykht.proj.coupon.utils.UtilsApi;
import com.ykht.proj.coupon.vo.FxBrandPersonVo;
import com.ykht.proj.coupon.vo.FxWaiterExtVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * 服务员扩展表
 *
 * @author proj code generator
 * @date 2021-02-01 19:00:18
 */
@RestController
@AllArgsConstructor
@RequestMapping("/fxwaiterext")
@Api(value = "fxwaiterext", tags = "服务员扩展表管理")
public class FxWaiterExtController {

	private final FxWaiterExtService fxWaiterExtService;
	/**
	 * 用户 服务 Api
	 */
	private final RemoteUserService remoteUserService;
	/**
	 * 门店 Api
	 */
	private final CnShopService cnShopService;
	/**
	 * 品牌 Api
	 */
	private final CnBrandService cnBrandService;
	/**
	 * 公司 Api
	 */
	private final CnCompanyService cnCompanyService;
	/**
	 * 分销 服务
	 */
	private final FxRewardService fxRewardService;
	/**
	 * 提现
	 */
	private final FxWithdrawalService fxWithdrawalService;
	/**
	 * 饭友服务
	 */
	private final FxBrandPersonService fxBrandPersonService;

	//	@PreAuthorize("@pms.hasPermission('coupon_fxwaiterext_view')")
	@ApiOperation(value = "分销列表分页(服务员  门店  品牌  公司)", notes = "分销列表分页 (服务员  门店  品牌  公司)")
	@GetMapping("/page")
	public R<IPage<FxWaiterExtVo>> page(Page page, FxWaiterExtVo fxWaiterExtVo) {
		if (null == fxWaiterExtVo.getLookRoleType()) {
			return R.failed("请选择查看类型");
		}
		IPage<FxWaiterExtVo> waiterExtServicePage = new Page<>();
		fxWaiterExtVo.setLoginRoleType(SecurityUtils.getUser().getUserType());
		fxWaiterExtVo.setLoginId(SecurityUtils.getSjId());
		if (null != fxWaiterExtVo.getNickName() && !"".equals(fxWaiterExtVo.getNickName())) {
			List<SysUser> userList = remoteUserService.findByNickName(fxWaiterExtVo.getNickName());
			if (userList.size() > 0) {
				List<Long> userIds = userList.stream().map(itme -> Long.valueOf(itme.getUserId())).collect(Collectors.toList());
				fxWaiterExtVo.setUserIds(userIds);
			} else {
				return R.ok(waiterExtServicePage);
			}
		}
		if (null != fxWaiterExtVo.getUserPhone() && !"".equals(fxWaiterExtVo.getUserPhone())) {
			List<SysUser> userList = remoteUserService.findByUserPhone(fxWaiterExtVo.getUserPhone());
			if (userList.size() > 0) {
				List<Long> userIds = userList.stream().map(itme -> Long.valueOf(itme.getUserId())).collect(Collectors.toList());
				fxWaiterExtVo.setUserIds(userIds);
			} else {
				return R.ok(waiterExtServicePage);
			}
		}
		waiterExtServicePage = fxWaiterExtService.findPage(page, fxWaiterExtVo);
		// 判断是否查看的是 服务员， 并给服务员赋值 姓名 电话
		if (LookRoleTypeEnum.LOOK_ROLE_TYPE_1.getValue().equals(fxWaiterExtVo.getLookRoleType())) {
			List<FxWaiterExtVo> records = waiterExtServicePage.getRecords();
			if (records.size() > 0) {
				List<Long> ids = records.stream().map(itme -> Long.valueOf(itme.getLoginId())).collect(Collectors.toList());
				List<SysUser> userList = remoteUserService.userByIds(ids);
				records.stream().forEach(itme -> {
					userList.stream().forEach(user -> {
						if (itme.getLoginId().equals(Long.valueOf(user.getUserId()))) {
							itme.setUsername(user.getUsername());
							itme.setNickName(user.getNickName());
							itme.setUserPhone(user.getPhone());
						}
					});
				});
				waiterExtServicePage.setRecords(records);
			}
		}
		return R.ok(waiterExtServicePage);
	}

	@ApiOperation(value = "分销记录(服务员  门店  品牌  公司 的统计)", notes = "分销记录(服务员  门店  品牌  公司 的统计)")
	@GetMapping("/pageCount")
	public R<FxWaiterExtVo> pageCount(FxWaiterExtVo fxWaiterExtVo) {
		if (null == fxWaiterExtVo.getLookRoleType()) {
			return R.failed("请选择查看类型");
		}
		Integer userType = SecurityUtils.getUser().getUserType();
		Long sjId = SecurityUtils.getSjId();
		if (1 == fxWaiterExtVo.getLookRoleType()) {
			QueryWrapper<FxWaiterExt> queryWrapper = new QueryWrapper<>();
			queryWrapper.lambda().eq(FxWaiterExt::getDelFlag, 0);
			switch (UserTypeEnum.getThisByVal(userType)) {
				case company:
					queryWrapper.lambda().eq(FxWaiterExt::getCompanyId, sjId);
					break;
				case brand:
					queryWrapper.lambda().eq(FxWaiterExt::getBrandId, sjId);
					break;
				case shop:
					queryWrapper.lambda().eq(FxWaiterExt::getShopId, sjId);
					break;
			}
			queryWrapper.lambda().groupBy(FxWaiterExt::getId);
			List<FxWaiterExt> count = fxWaiterExtService.list(queryWrapper);
			fxWaiterExtVo.setWaiterCount(count.size());
		} else {
			List<FxReward> companyCount = new ArrayList<>();
			List<FxReward> brandCount = new ArrayList<>();
			List<FxReward> shopCount = new ArrayList<>();
			switch (UserTypeEnum.getThisByVal(userType)) {
				case admin:
					companyCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class).groupBy(FxReward::getCompanyId));
					fxWaiterExtVo.setCompanyCount(companyCount.size());
					brandCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class).groupBy(FxReward::getBrandId));
					fxWaiterExtVo.setBrandCount(brandCount.size());
					shopCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class).groupBy(FxReward::getShopId));
					fxWaiterExtVo.setShopCount(shopCount.size());
					break;
				case company:
					companyCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class)
							.eq(FxReward::getCompanyId, sjId).groupBy(FxReward::getCompanyId));
					fxWaiterExtVo.setCompanyCount(companyCount.size());
					// 品牌
					brandCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class)
							.eq(FxReward::getCompanyId, sjId).groupBy(FxReward::getBrandId));
					fxWaiterExtVo.setBrandCount(brandCount.size());
					// 门店
					shopCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class)
							.eq(FxReward::getCompanyId, sjId).groupBy(FxReward::getShopId));
					fxWaiterExtVo.setShopCount(shopCount.size());
					break;

				case brand:
					companyCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class)
							.eq(FxReward::getBrandId, sjId).groupBy(FxReward::getCompanyId));
					fxWaiterExtVo.setCompanyCount(companyCount.size());
					// 品牌
					brandCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class)
							.eq(FxReward::getBrandId, sjId).groupBy(FxReward::getBrandId));
					fxWaiterExtVo.setBrandCount(brandCount.size());
					shopCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class)
							.eq(FxReward::getBrandId, sjId).groupBy(FxReward::getShopId));
					fxWaiterExtVo.setShopCount(shopCount.size());
					break;

				case shop:
					companyCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class)
							.eq(FxReward::getShopId, sjId).groupBy(FxReward::getCompanyId));
					fxWaiterExtVo.setCompanyCount(companyCount.size());
					// 品牌
					brandCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class)
							.eq(FxReward::getShopId, sjId).groupBy(FxReward::getBrandId));
					fxWaiterExtVo.setBrandCount(brandCount.size());
					shopCount = fxRewardService.list(Wrappers.lambdaQuery(FxReward.class)
							.eq(FxReward::getShopId, sjId).groupBy(FxReward::getShopId));
					fxWaiterExtVo.setShopCount(shopCount.size());
					break;
			}
		}
		return R.ok(fxWaiterExtVo);
	}


	@ApiOperation(value = "提现记录的维度(服务员  门店  品牌  公司 的统计)", notes = "提现记录的维度(服务员  门店  品牌  公司 的统计)")
	@GetMapping("/getWithdrawalPageCount")
	public R<FxWaiterExtVo> getWithdrawalPageCount(FxWaiterExtVo fxWaiterExtVo) {
		if (null == fxWaiterExtVo.getLookRoleType()) {
			return R.failed("请选择查看类型");
		}
		Integer userType = SecurityUtils.getUser().getUserType();
		Long sjId = SecurityUtils.getSjId();
		if (1 == fxWaiterExtVo.getLookRoleType()) {
			QueryWrapper<FxWithdrawal> queryWrapper = new QueryWrapper<>();
			queryWrapper.lambda().eq(FxWithdrawal::getDelFlag, 0);
			switch (UserTypeEnum.getThisByVal(userType)) {
				case company:
					queryWrapper.lambda().eq(FxWithdrawal::getCompanyId, sjId);
					break;
				case brand:
					queryWrapper.lambda().eq(FxWithdrawal::getBrandId, sjId);
					break;
				case shop:
					queryWrapper.lambda().eq(FxWithdrawal::getShopId, sjId);
					break;
			}
			queryWrapper.lambda().groupBy(FxWithdrawal::getWaiterId);
			List<FxWithdrawal> count = fxWithdrawalService.list(queryWrapper);
			fxWaiterExtVo.setWaiterCount(count.size());
		} else {
			List<FxWithdrawal> companyCount = new ArrayList<>();
			List<FxWithdrawal> brandCount = new ArrayList<>();
			List<FxWithdrawal> shopCount = new ArrayList<>();
			switch (UserTypeEnum.getThisByVal(userType)) {
				case admin:
					companyCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class).groupBy(FxWithdrawal::getCompanyId));
					fxWaiterExtVo.setCompanyCount(companyCount.size());
					brandCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class).groupBy(FxWithdrawal::getBrandId));
					fxWaiterExtVo.setBrandCount(brandCount.size());
					shopCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class).groupBy(FxWithdrawal::getShopId));
					fxWaiterExtVo.setShopCount(shopCount.size());
					break;
				case company:
					companyCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class)
							.eq(FxWithdrawal::getCompanyId, sjId)
							.groupBy(FxWithdrawal::getCompanyId));
					fxWaiterExtVo.setCompanyCount(companyCount.size());
					// 品牌
					brandCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class)
							.eq(FxWithdrawal::getCompanyId, sjId)
							.groupBy(FxWithdrawal::getBrandId));
					fxWaiterExtVo.setBrandCount(brandCount.size());
					// 门店
					shopCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class)
							.eq(FxWithdrawal::getCompanyId, sjId)
							.groupBy(FxWithdrawal::getShopId));
					fxWaiterExtVo.setShopCount(shopCount.size());
					break;
				case brand:
					companyCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class)
							.eq(FxWithdrawal::getBrandId, sjId)
							.groupBy(FxWithdrawal::getCompanyId));
					fxWaiterExtVo.setCompanyCount(companyCount.size());
					// 品牌
					brandCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class)
							.eq(FxWithdrawal::getBrandId, sjId)
							.groupBy(FxWithdrawal::getBrandId));
					fxWaiterExtVo.setBrandCount(brandCount.size());
					shopCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class)
							.eq(FxWithdrawal::getBrandId, sjId)
							.groupBy(FxWithdrawal::getShopId));
					fxWaiterExtVo.setShopCount(shopCount.size());
					break;
				case shop:
					companyCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class)
							.eq(FxWithdrawal::getShopId, sjId)
							.groupBy(FxWithdrawal::getCompanyId));
					fxWaiterExtVo.setCompanyCount(companyCount.size());
					// 品牌
					brandCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class)
							.eq(FxWithdrawal::getShopId, sjId)
							.groupBy(FxWithdrawal::getBrandId));
					fxWaiterExtVo.setBrandCount(brandCount.size());
					shopCount = fxWithdrawalService.list(Wrappers.lambdaQuery(FxWithdrawal.class)
							.eq(FxWithdrawal::getShopId, sjId)
							.groupBy(FxWithdrawal::getShopId));
					fxWaiterExtVo.setShopCount(shopCount.size());
					break;
			}
		}
		return R.ok(fxWaiterExtVo);
	}


	/**
	 * 分销记录-分销详情 ----基本资料
	 *
	 * @return R
	 */
	@ApiOperation(value = "分销记录-分销详情 ----基本资料")
	@PostMapping("getByIdAndCount")
	public R<FxWaiterExtVo> getByIdAndCount(@RequestBody FxWaiterExtVo fxWaiterExtVo) {
		try {
			FxWaiterExtVo fxWaiterExtVo1 = new FxWaiterExtVo();
			Long userId = null;
			//  查看门店
			if (LookRoleTypeEnum.LOOK_ROLE_TYPE_2.getValue().equals(fxWaiterExtVo.getLookRoleType())) {
				fxWaiterExtVo1.setWaiterCount(fxWaiterExtService.count(new QueryWrapper<FxWaiterExt>()
						.lambda().eq(FxWaiterExt::getShopId, fxWaiterExtVo.getShopId())
						.eq(FxWaiterExt::getWorkState, WorkStateEnum.WORK_STATE_1.getValue())));
				CnShop shop = cnShopService.getById(fxWaiterExtVo.getShopId());
				if (shop != null) fxWaiterExtVo1.setShopName(shop.getName());
				CnBrand brand = cnBrandService.getById(shop.getBrandId());
				if (brand != null) fxWaiterExtVo1.setBrandName(brand.getBrandName());
				CnCompany company = cnCompanyService.getById(shop.getCompanyId());
				fxWaiterExtVo1.setCompanyName(company.getName());
				fxWaiterExtVo1.setCompanyPhone(company.getPhone());
				userId = shop.getLoginId();
				// 查看品牌
			} else if (LookRoleTypeEnum.LOOK_ROLE_TYPE_3.getValue().equals(fxWaiterExtVo.getLookRoleType())) {
				fxWaiterExtVo1.setWaiterCount(fxWaiterExtService.count(new QueryWrapper<FxWaiterExt>()
						.lambda().eq(FxWaiterExt::getBrandId, fxWaiterExtVo.getBrandId())
						.eq(FxWaiterExt::getWorkState, WorkStateEnum.WORK_STATE_1.getValue())));
				fxWaiterExtVo1.setShopCount(cnShopService.count(new QueryWrapper<CnShop>()
						.lambda().eq(CnShop::getBrandId, fxWaiterExtVo.getBrandId())
						.eq(CnShop::getDisplay, 0)));
				CnBrand brand = cnBrandService.getById(fxWaiterExtVo.getBrandId());
				fxWaiterExtVo1.setBrandName(brand.getBrandName());
				CnCompany company = cnCompanyService.getById(brand.getCompanyId());
				fxWaiterExtVo1.setCompanyName(company.getName());
				fxWaiterExtVo1.setCompanyPhone(company.getPhone());
				userId = brand.getLoginId();
				// 查看公司
			} else if (LookRoleTypeEnum.LOOK_ROLE_TYPE_4.getValue().equals(fxWaiterExtVo.getLookRoleType())) {
				fxWaiterExtVo1.setWaiterCount(fxWaiterExtService.count(new QueryWrapper<FxWaiterExt>()
						.lambda().eq(FxWaiterExt::getCompanyId, fxWaiterExtVo.getCompanyId())
						.eq(FxWaiterExt::getWorkState, WorkStateEnum.WORK_STATE_1.getValue())));
				fxWaiterExtVo1.setShopCount(cnShopService.count(new QueryWrapper<CnShop>()
						.lambda().eq(CnShop::getCompanyId, fxWaiterExtVo.getCompanyId())
						.eq(CnShop::getDisplay, 0)));
				fxWaiterExtVo1.setBrandCount(cnBrandService.count(new QueryWrapper<CnBrand>()
						.lambda().eq(CnBrand::getCompanyId, fxWaiterExtVo.getCompanyId())
						.eq(CnBrand::getDisplay, 0)));
				CnCompany company = cnCompanyService.getById(fxWaiterExtVo.getCompanyId());
				fxWaiterExtVo1.setCompanyName(company.getName());
				fxWaiterExtVo1.setCompanyPhone(company.getPhone());
				userId = company.getLoginId();
				// 查看服务员
			} else if (LookRoleTypeEnum.LOOK_ROLE_TYPE_1.getValue().equals(fxWaiterExtVo.getLookRoleType())) {
				FxWaiterExt fxWaiterExt = fxWaiterExtService.getById(fxWaiterExtVo.getId());
				CnShop cnShop = cnShopService.getById(fxWaiterExt.getShopId());
				if (cnShop != null) fxWaiterExtVo1.setShopName(cnShop.getName());
				CnBrand brand = cnBrandService.getById(fxWaiterExt.getBrandId());
				if (brand != null) fxWaiterExtVo1.setBrandName(brand.getBrandName());
				CnCompany company = cnCompanyService.getById(fxWaiterExt.getCompanyId());
				fxWaiterExtVo1.setCompanyName(company.getName());
				fxWaiterExtVo1.setCompanyPhone(company.getPhone());
				userId = fxWaiterExt.getLoginId();
			}
			UserVO userVO = remoteUserService.getByIdUser(userId);
			fxWaiterExtVo1.setUsername(userVO.getUsername());
			fxWaiterExtVo1.setUserPhone(userVO.getPhone());
			fxWaiterExtVo1.setNickName(userVO.getNickName());
			fxWaiterExtVo1.setLoginId(userId);
			fxWaiterExtVo1.setLookRoleType(fxWaiterExtVo.getLookRoleType());
			return R.ok(fxWaiterExtVo1);
		} catch (Exception e) {
			e.printStackTrace();
			return R.failed();
		}
	}

	/**
	 * 记录详情的饭友 分页查询（饭友概况）统计
	 *
	 * @return R
	 */
	@ApiOperation(value = "记录详情的饭友 分页查询（饭友概况）统计")
	@PostMapping("getFanYouListPageCount")
	public R<FxWaiterExtVo> getFanYouListPageCount(@RequestBody FxWaiterExtVo fxWaiterExtVo) {
		try {
			fxWaiterExtVo.setLoginRoleType(SecurityUtils.getUser().getUserType());
			FxWaiterExtVo fxWaiterExtVo1 = fxWaiterExtService.getFanYouListPageCount(fxWaiterExtVo);
			return R.ok(fxWaiterExtVo1);
		} catch (Exception e) {
			e.printStackTrace();
			return R.failed();
		}
	}

	/**
	 * 记录详情的饭友 分页查询
	 *
	 * @param page            分页对象
	 * @param fxBrandPersonVo
	 * @return
	 */
	@ApiOperation(value = "记录详情的饭友 分页查询", notes = "记录详情的饭友 分页查询")
	@GetMapping("/getFanYouListPage")
	public R<IPage<FxBrandPersonVo>> getFanYouListPage(Page page, FxBrandPersonVo fxBrandPersonVo) {
		fxBrandPersonVo.setLoginRoleType(SecurityUtils.getUser().getUserType());
		IPage<FxBrandPersonVo> fanYouListPage = fxBrandPersonService.getFanYouListPage(page, fxBrandPersonVo);
//		IPage<FxWaiterExtVo> personVoIPage = fxWaiterExtService.getFanYouListPage(page, fxWaiterExtVo);
		return R.ok(fanYouListPage);
	}

	/**
	 * 获取服务员信息
	 *
	 * @return
	 */
	@ApiOperation(value = "获取服务员信息", notes = "获取服务员信息")
	@GetMapping("/getWaiterData")
	public FxWaiterExt getWaiterData() {
		FxWaiterExt waiterExt = fxWaiterExtService.getOne(Wrappers.lambdaQuery(FxWaiterExt.class)
				.eq(FxWaiterExt::getLoginId, SecurityUtils.getUserId())
				.eq(FxWaiterExt::getWorkState, 1).eq(FxWaiterExt::getDelFlag, 0));
		return waiterExt;
	}


	@ApiOperation(value = "获取服务员列表", notes = "获取服务员列表")
	@GetMapping("/getWaiterExtPageList")
	public R<IPage<FxWaiterExtVo>> getWaiterExtPageList(Page page, FxWaiterExtVo fxWaiterExtVo) {
		IPage<FxWaiterExtVo> waiterExtServicePage = new Page<>();
		Integer userType = SecurityUtils.getUser().getUserType();
		fxWaiterExtVo.setLoginRoleType(userType);
		fxWaiterExtVo.setLoginId(SecurityUtils.getSjId());
		if ((null != fxWaiterExtVo.getNickName() && !"".equals(fxWaiterExtVo.getNickName()))
				|| (null != fxWaiterExtVo.getUserPhone() && !"".equals(fxWaiterExtVo.getUserPhone()))) {
			UserDTO userDTO = new UserDTO();
			userDTO.setNickName(fxWaiterExtVo.getNickName());
			userDTO.setPhone(fxWaiterExtVo.getUserPhone());
			List<SysUser> userList = remoteUserService.findByUserNameAndUserPhone4WaiterExtList(userDTO);
			if (null != userList && userList.size() > 0) {
				List<Long> userIds = userList.stream().map(itme -> Long.valueOf(itme.getUserId())).collect(Collectors.toList());
				fxWaiterExtVo.setUserIds(userIds);
			} else {
				return R.ok(waiterExtServicePage);
			}
		}
		waiterExtServicePage = fxWaiterExtService.getWaiterExtPageList(page, fxWaiterExtVo);
		List<FxWaiterExtVo> records = waiterExtServicePage.getRecords();
		if (null != records && records.size() > 0) {
			List<Long> userIds = records.stream().map(itme -> itme.getLoginId()).collect(Collectors.toList());
			List<SysUser> userList = remoteUserService.userByIds(userIds);
			records.stream().forEach(itme -> {
				userList.stream().forEach(user -> {
					if (itme.getLoginId().equals(Long.valueOf(user.getUserId()))) {
						itme.setUsername(user.getUsername());
						itme.setNickName(user.getNickName());
						itme.setUserPhone(user.getPhone());
						itme.setSex(user.getSex());
					}
				});
			});
			waiterExtServicePage.setRecords(records);
		}
		return R.ok(waiterExtServicePage);
	}

	@ApiOperation(value = "获取服务员", notes = "获取服务员列表")
	@GetMapping("/getWaiterIdList")
	public R<List<Long>> getWaiterIdList() {
		return R.ok(fxWaiterExtService.getWaiterIdList());
	}

	@ApiOperation(value = "获取服务员", notes = "获取服务员列表")
	@GetMapping("/getWaiterIdList1111111")
	public R<List<Long>> getWaiterIdList1111111() {
		List<Long> waiterIdList = UtilsApi.getWaiterIdList();
		FxWaiterExt waiterId = UtilsApi.getWaiterId();
		System.out.println(waiterId);
		return R.ok(waiterIdList);
	}

}
